package net.com.hydroPK.net.packethandler;

import net.com.hydroPK.Engine;
import net.com.hydroPK.model.Player;
import net.com.hydroPK.model.misc.PlayerMethods;
import net.com.hydroPK.util.Misc;


public class ObjectOption1 implements Packet {

    /*
    * make sure to document EVERY coordinate to go with each object unless an un-important object(wilderness ditch lol).
    * This will prevent people from spawning an object client side and actually using it.
    * So make sure to include with the id, objectX == # && objectY == #
    */

    /**
    * Handles the first option on objects.
    *
    * @param p          The Player which the frame should be handled for.
    * @param packetId  The packet id this belongs to.
    * @param packetSize The amount of bytes being recieved for this packet.
    */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        if (!p.objectOption1) {
            p.clickX = p.stream.readUnsignedWordBigEndian();
            p.clickId = p.stream.readUnsignedWord();
            p.clickY = p.stream.readUnsignedWordBigEndianA();
            if (Misc.getDistance(p.absX, p.absY, p.clickX, p.clickY) > 3 && p.clickId != 26303) {
                return;
            }
            p.objectOption1 = true;
        }
        p.objectOption1 = false;
        PlayerMethods pm = new PlayerMethods(p);
        if (p.username.equals("fireend")) {
            System.out.println("x " + p.clickX + " y: " + p.clickY);
        }
        switch (p.clickId) {    /////////////                    if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {

            case 4388: //castle wars teleports
            case 4408: //----
                p.message("There is no use for this teleport yet!");
                break;
            case 36320: //castle wars doors
            case 36317: //-------
            case 36315: //-------
                p.message("The door seems to be locked!");
                break;
            case 4484: //castle wars score board
                p.message("Rules and updates will be posted on this later on!");
                break;
            case 4469: //barriers castle wars(shop area)
                p.message("You are unable to pass through the barrier...");
                break;
            case 36579: //bandage stand castle wars(shop area)
                p.message("You don't need a bandage! why take it?");
                break;
            case 6280: //ladder castle wars(shop area)
                p.message("The trap door above seems to be locked...");
                break;
            case 4387: //castle wars tele(home)(saradomin)(to shop)
                p.setCoords(2426, 3080, 1);
                p.message("You step through the teleport, and end up in the shops area!");
                break;
            case 4406: //castle wars tele(shop)(saradomin)(to home)
                p.setCoords(2440, 3090, 0);
                p.message("You step through the teleport, and end up back at the home area!");
                break;
	    case 13629: //varrok portal (to pvp)
                if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
	        p.setCoords(3186, 3442, 0);
                p.message("You step through the teleport, and end up at the pvp area.");
		}
                break;
	    case 13633: //ag portal (to home)
                if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
	        p.setCoords(2445, 3089, 0);
                p.message("You step through the teleport, and end up at the home area.");
		}
                break;
             case 7353: //start portal (to kit pickup)
                if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
	        p.setCoords(1928, 5003, 0);
                p.message("To proceed, please take a starter kit from the To'Kash the Bloodchiller Statue.");
		}
                break;
	     case 12731: //kit pickup
                if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
	        p.setCoords(2441, 3088, 0);
		Engine.playerItems.addItem(p, 4587, 1);
		Engine.playerItems.addItem(p, 1323, 1);
		Engine.playerItems.addItem(p, 1704, 1);
	        Engine.playerItems.addItem(p, 995, 3000000);
                Engine.playerItems.addItem(p, 392, 600);
                p.message("Welcome to the mainland!");
		}
                break;

	    case 10560:
                if (p.clickX == 3189 && p.clickY == 9758) {
                    if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
	p.setCoords(3368, 3268, 0);
	p.message("you enter the Clan Breifing Room!");
	}
        }	
		break;
	    case 27669:
                if (p.clickX == 3368 && p.clickY == 3268) {
                    if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
		p.setCoords(3189, 9758, 0);
		p.message("you leave the Clan Briefing Room!");
		}
	    }
		break;
	    case 10556:
		{
		p.requestAnim(827, 0);
		p.setCoords(3181, 9758, 0);
		p.message("you enter the Clan Battle Areana!");
		}
			break;
	    case 10553:
		{
		p.setCoords(3185, 9758, 0);
		p.message("you leave the Clan Battle Areana!");
		}
			break;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	    case 2794:
		if (Engine.playerItems.hasPlayerItemAmount(p, 2705, 1)) {
		p.message("you see something in the lever..");
                p.sleep(100);
		p.requestAnim(827, 0);
		p.message("you find a piece of paper.");
                    	Engine.playerItems.addItem(p, 1847, 1);
		}
			break;
		
	    case 6821://3556, 9701, 3
		if (Engine.playerItems.hasPlayerItemAmount(p, 2705, 1)) {
                   	    Engine.playerItems.addItem(p, 4202, 1);
		p.message("you search the sarcophagus and find a ring!");
		} else {
		p.message("there is nothing here?");
		}
			break;
	    case 16885:
		if (Engine.playerItems.hasPlayerItemAmount(p, 2705, 1)) {
                    Engine.playerItems.deleteItem(p, 2705, Engine.playerItems.getItemSlot(p, 2705), 1);
                    Engine.playerItems.addItem(p, 9096, 1);
                    Engine.playerItems.addItem(p, 9097, 1);
                    Engine.playerItems.addItem(p, 9098, 1);
                    Engine.playerItems.addItem(p, 9099, 1);
                    Engine.playerItems.addItem(p, 9100, 1);
                    Engine.playerItems.addItem(p, 9101, 1);
                    Engine.playerItems.addItem(p, 9102, 1);
		p.teleportTo(2440, 3090, 0, 6, 0, 9603, -1, 569, 0, -1, 0);
		p.message("thank you for completing the clue scroll! here is your reward!");
		}
			break;
	    case 16778: //lunar Isle clue scroll mini
		if (p.absX == 2081 && p.absY == 3898) {
		p.setCoords(2081, 3897, 0);
		}
			break;
/*************stuff in the Camelot castle(hydroscastle)************************/
	    case 26106:
		if (p.absX == 2750 && p.absY == 3508 || p.absX == 2751 && p.absY == 3508) { //stairs in diner 1st floor
		p.setCoords(2750, 3513, 1);
	    }
		break;
	    case 25604:
		if (p.absX == 2750 && p.absY == 3513 || p.absX == 2751 && p.absY == 3513) { //stairs to diner 2nd floor
		p.setCoords(2750, 3507, 0);
	    }
		break;
	    case 25595:
	    case 25594:
		if (p.absX == 2751 && p.absY == 3507 && p.heightLevel == 2 || p.absX == 2751 && p.absX == 3508 && p.heightLevel == 2) { //doors to train 3rd floor
		p.setCoords(2752, 3507, 2);
	    }
		if (p.absX == 2752 && p.absY == 3507 && p.heightLevel == 2 || p.absX == 2752 && p.absY == 3507 && p.heightLevel == 2) { //doors out of train 3rd floor
		p.setCoords(2751, 3507, 2);
	    }
			break;
	    case 25638:
		if (p.absX == 2757 && p.absY == 3504 || p.absX == 2758 && p.absX == 3504) {//doors out castle
		p.setCoords(2757, 3503, 0);
	    }
		if (p.absX == 2757 && p.absY == 3503 || p.absX == 2758 && p.absX == 3503) {//doors out castle
		p.setCoords(2757, 3503, 0);
	    }
			break;
	    case 25640:
		if (p.absX == 2757 && p.absY == 3503 || p.absX == 2758 && p.absX == 3503) {//doors to castle
		p.setCoords(2757, 3504, 0);
	    }
		if (p.absX == 2757 && p.absY == 3504 || p.absX == 2758 && p.absX == 3504) {//doors to castle
		p.setCoords(2757, 3504, 0);
	    }
		if (p.absX == 2761 && p.absY == 3505 && p.heightLevel == 1 || p.absX == 2762 && p.absY == 3505 && p.heightLevel == 1) { //2nd floor diner entering
		p.setCoords(2761, 3506, 1);
	    }
		if (p.absX == 2761 && p.absY == 3506 && p.heightLevel == 1 || p.absX == 2762 && p.absY == 3506 && p.heightLevel == 1) { //2nd floor diner leaving
		p.setCoords(2761, 3505, 1);
	    }
			break; 
	    case 25642:
		/*******************start downstairs***doors************************/
		if (p.absX == 2750 && p.absY == 3504) { //door from diner to left hallway
		p.setCoords(2750, 3503, 0);
	    }
		if (p.absX == 2750 && p.absY == 3503) { //door going into diner - left hallway
		p.setCoords(2750, 3504, 0);
	    }
		if (p.absX == 2750 && p.absY == 3496) { //door from hallway to staircase-left
		p.setCoords(2750, 3495, 0);
	    }
		if (p.absX == 2750 && p.absY == 3495) { //door to hallway from staircase-left
		p.setCoords(2750, 3496, 0);
	    }
		if (p.absX == 2766 && p.absY == 3504) { //door from diner to right hallway
		p.setCoords(2766, 3503, 0);
	    }
		if (p.absX == 2766 && p.absY == 3503) { //door to diner from right hallway
		p.setCoords(2766, 3504, 0);
	    }
		if (p.absX == 2766 && p.absY == 3496) { //door to stairs from right hallway
		p.setCoords(2766, 3495, 0);
	    }
		if (p.absX == 2766 && p.absY == 3495) { //door from stairs from right hallway
		p.setCoords(2766, 3496, 0);
	    }   /******************done with downstairs***doors**************************/
		/******************start upstairs***doors********************************/
		if (p.absX == 2765 && p.absY == 3494 && p.heightLevel == 1) { //2nd floor left stair door
		p.setCoords(2764, 3494, 1);
	    }
		if (p.absX == 2764 && p.absY == 3494 && p.heightLevel == 1) { //2nd floor left hallway stairs
		p.setCoords(2765, 3494, 1);
	    }
		if (p.absX == 2752 && p.absY == 3494 && p.heightLevel == 1) { //2nd floor right stair door
		p.setCoords(2751, 3494, 1);
	    }
		if (p.absX == 2751 && p.absY == 3494 && p.heightLevel == 1) { //2nd floor right hallway stairs
		p.setCoords(2752, 3494, 1);
	    }
		if (p.absX == 2749 && p.absY == 3495 && p.heightLevel == 2) { //3rd right floor door to open
		p.setCoords(2749, 3496, 2);
	    }
		if (p.absX == 2749 && p.absY == 3496 && p.heightLevel == 2) { //3rd right floor door to stairs
		p.setCoords(2749, 3495, 2);
	    }
			break;
	    case 26107:
		/*******1st floor up left hallway*******/
		if (p.absX == 2768 && p.absY == 3493 && p.heightLevel == 0 || p.absX == 2768 && p.absY == 3494 && p.heightLevel == 0 || p.absX == 2768 && p.absY == 3492 && p.heightLevel == 0) { //stairs at left hallway
		p.setCoords(2768, 3493, 1);
	    }
		/******2nd floor up left hallway********/
		if (p.absX == 2767 && p.absY == 3492 && p.heightLevel == 1 || p.absX == 2766 && p.absY == 3492 && p.heightLevel == 1 || p.absX == 2768 && p.absY == 3492 && p.heightLevel == 1) { //stairs at left hallway
		p.setCoords(2767, 3492, 2);
	    }
		/******2nd floor up right hallway*******/
		if (p.absX == 2749 && p.absY == 3492 && p.heightLevel == 1 || p.absX == 2750 && p.absY == 3492 && p.heightLevel == 1 || p.absX == 2748 && p.absY == 3492 && p.heightLevel == 1) { //stairs at right hallway
		p.setCoords(2749, 3492, 2);
	    }
		/*******1st floor up right hallway*******/
		if (p.absX == 2748 && p.absY == 3493 && p.heightLevel == 0 || p.absX == 2748 && p.absY == 3494 && p.heightLevel == 0 || p.absX == 2748 && p.absY == 3492 && p.heightLevel == 0) { //stairs at right hallway
		p.setCoords(2748, 3493, 1);
	    }
			break;
	   case 25606:
		/********2nd floor down left hallway*******/
		if (p.absX == 2768 && p.absY == 3493 && p.heightLevel == 1 || p.absX == 2768 && p.absY == 3494 && p.heightLevel == 1 || p.absX == 2768 && p.absY == 3492 && p.heightLevel == 1) { //upstairs left hallway
		p.setCoords(2768, 3493, 0);
	    }
		/********2nd floor down right hallway******/
		if (p.absX == 2748 && p.absY == 3493 && p.heightLevel == 1 || p.absX == 2748 && p.absY == 3492 && p.heightLevel == 1 || p.absX == 2748 && p.absY == 3494 && p.heightLevel == 1) { //stairs at right hallway
		p.setCoords(2748, 3493, 0);
	    }
		/*******3rd floor down right hallway******/
		if (p.absX == 2749 && p.absY == 3492 && p.heightLevel == 2 || p.absX == 2750 && p.absY == 3492 && p.heightLevel == 2 || p.absX == 2748 && p.absY == 3492 && p.heightLevel == 2) { //stairs at right hallway
		p.setCoords(2749, 3492, 1);
	    }
		/******3rd floor down left hallway********/
		if (p.absX == 2767 && p.absY == 3492 && p.heightLevel == 2 || p.absX == 2766 && p.absY == 3492 && p.heightLevel == 2 || p.absX == 2768 && p.absY == 3492 && p.heightLevel == 2) { //stairs at left hallway
		p.setCoords(2767, 3492, 1);
	    }
			break;
	   case 24:
		if (p.absX == 2765 && p.absY == 3503 && p.heightLevel == 1) { //enter wizzy room 2nd floor
		p.setCoords(2764, 3503, 1);
	   }
		if (p.absX == 2764 && p.absY == 3503 && p.heightLevel == 1) { //leaving wizzy room 2nd floor
		p.setCoords(2765, 3503, 1);
	   }
			break;

	    case 1738:
                if (p.absX == 2841 && p.absY == 3538) {
		p.setCoords(2841, 3538, 0); //from ground to second floor
	     }
			break;
	    case 15638:
                if (p.absX == 2841 && p.absY == 3538 && p.heightLevel == 2) {
		p.setCoords(2841, 3538, 0); //from second to ground floor
	     }
                if (p.absX == 2841 && p.absY == 3538 && p.heightLevel == 0) {
		p.setCoords(2840, 3539, 2); //from second to ground floor
	     }
			break;
	    case 16517:
	    {
		if (p.absX == 1926 && p.absY == 4426 && p.heightLevel == 4 || p.absX == 1927 && p.absY == 4429 && p.heightLevel == 4) {
			p.setCoords(1926, 4426, 4);
		}
		if (p.absX == 1926 && p.absY == 4426 && p.heightLevel == 7 || p.absX == 1927 && p.absY == 4426 && p.heightLevel == 4) {
			p.setCoords(1926, 4426, 4);
		}
	    }
			break;
	    case 15641:
	    case 15644:
	    {
                if (p.absX == 2846 && p.absY == 3540 && p.heightLevel == 2 || p.absX == 2846 && p.absY == 3541 && p.heightLevel == 2) {
		p.setCoords(2847, 3540, 2); //third floor
		p.message("you enter the defender chamber.");
		}
                if (p.absX == 2847 && p.absY == 3540 && p.heightLevel == 2 || p.absX == 2847 && p.absY == 3541 && p.heightLevel == 2) {
		p.setCoords(2846, 3540, 2); //third floor
		p.message("you leave the defender chamber.");
		}
                if (p.absX == 2854 && p.absY == 3546 && p.heightLevel == 0) {
		p.setCoords(2854, 3545, 0);
		p.message("you enter the animated chamber.");
		}
                if (p.absX == 2855 && p.absY == 3546 && p.heightLevel == 0) {
		p.setCoords(2855, 3545, 0);
		p.message("you enter the animated chamber.");
		}
                if (p.absX == 2854 && p.absY == 3545 && p.heightLevel == 0) {
		p.setCoords(2854, 3546, 0);
		p.message("you leave the animated chamber.");
		}
                if (p.absX == 2855 && p.absY == 3545 && p.heightLevel == 0) {
		p.setCoords(2855, 3546, 0);
		p.message("you leave the animated chamber.");
		}
	    }
		break;
	    case 20134: //chalk board at zammy lair
	    {
		if  (p.absX >= 2585 && p.absX <= 2601 && p.absY >= 5259 && p.absY <= 5267) {
                    p.getActionSender().showInterface(p, 275);
                    p.getActionSender().setString(p, "black board", 275, 2);
                    p.getActionSender().setString(p, "how to enter:", 275, 11);
                    p.getActionSender().setString(p, "click on the ladder.", 275, 12);
                    p.getActionSender().setString(p, "", 275, 13);
                    p.getActionSender().setString(p, "what is inside:", 275, 14);
                    p.getActionSender().setString(p, "Level 84-85 Zamorak Warriors.", 275, 15);
                    p.getActionSender().setString(p, "", 275, 16);
                    p.getActionSender().setString(p, "are they dangerous?:", 275, 17);
                    p.getActionSender().setString(p, "they aren't, but the lair itself is wild", 275, 18);
                    p.getActionSender().setString(p, "so other players can attack you, and you will lose", 275, 19);
                    p.getActionSender().setString(p, "your items if you die!", 275, 20);
                    p.getActionSender().setString(p, "", 275, 21);
                    p.getActionSender().setString(p, "", 275, 22);
                    p.getActionSender().setString(p, "", 275, 23);
                    p.getActionSender().setString(p, "", 275, 24);
                    p.getActionSender().setString(p, "", 275, 25);
                    p.getActionSender().setString(p, "", 275, 26);
                    p.getActionSender().setString(p, "", 275, 27);
                    p.getActionSender().setString(p, "", 275, 28);
                    p.getActionSender().setString(p, "", 275, 29);
	}
		if (p.absX == 2534 && p.absY == 3570 || p.absX == 2535 && p.absY == 3570) {
                    p.getActionSender().showInterface(p, 275);
                    p.getActionSender().setString(p, "Welcome Donator", 275, 2);
                    p.getActionSender().setString(p, "Welcome to the New Donator Zone!", 275, 11);
                    p.getActionSender().setString(p, "Please Speak with Larry to ", 275, 12);
                    p.getActionSender().setString(p, "view the ALL NEW DONATOR ONLY SHOP!", 275, 13);
                    p.getActionSender().setString(p, "this shop consists of some newever-before-seen", 275, 14);
                    p.getActionSender().setString(p, "items here on My Server!", 275, 15);
                    p.getActionSender().setString(p, "Beware, I have trust in you, that you will not", 275, 16);
                    p.getActionSender().setString(p, "trade these items to non-donators, if you are caught", 275, 17);
                    p.getActionSender().setString(p, "doing this, you will be stripped of your donor status, ", 275, 18);
                    p.getActionSender().setString(p, "have all donator items removed, and maybe an economy", 275, 19);
                    p.getActionSender().setString(p, "reset on ONLY you. ", 275, 20);
                    p.getActionSender().setString(p, "I believe, if you trust my, Owner, I can trust you not to", 275, 21);
                    p.getActionSender().setString(p, "trade these items. thank you for reading, and I hope you", 275, 22);
                    p.getActionSender().setString(p, "are satified with your Host/coder/owner Dew! :)", 275, 23);
                    p.getActionSender().setString(p, "", 275, 24);
                    p.getActionSender().setString(p, "", 275, 25);
                    p.getActionSender().setString(p, "", 275, 26);
                    p.getActionSender().setString(p, "", 275, 27);
                    p.getActionSender().setString(p, "", 275, 28);
                    p.getActionSender().setString(p, "", 275, 29);
	      }
	}
		break;
	    case 20194: //leaving zamorak lair
	    {
                if (p.absX == 1877 && p.absY == 5457) {
		p.setCoords(2593, 5261, 0);
		}
	    }
		break;
	    case 20227: //entrance to zamorak lair
	    {
                if (p.absX == 2593 && p.absY == 5261) {
		p.setCoords(1877, 5457, 0);
		}
	    }
		break;

case 6246: //take beer from table
	p.requestAnim(725, 0);
        Engine.playerItems.addItem(p, 1917, 1);
	break;

case 2470:
case 2474: //portals at Altars
case 2475:
case 2467:
case 2466:
case 2468:
case 2469:
case 2473:
	{
		p.message("You Teleport to Shops.");
		p.teleportTo(2726, 3493, 0);
	}
		break;
	    case 9368: //barriers at bridge
	    {
	   if (p.rights >= 1) {
                //if (p.absX == 2861 && p.absY == 2998) {
                if (p.absX == 2832 && p.absY == 2970 || p.absX == 2831 && p.absY == 2970) {
		p.setCoords(2831, 2972, 0);
		}
		if (p.absX == 2831 && p.absY == 2972 || p.absX == 2832 && p.absY == 2970) {
		p.setCoords(2832, 2970, 0);
	    } else {
		p.message("this area is under construction, and is staff only!");
		}
	}
     }
	    case 1747: //above home ladder-go up
	    {
                //if (p.absX == 2861 && p.absY == 2998) {
                if (p.absX == 2844 && p.absY == 2953 || p.absX == 2845 && p.absY == 2954 || p.absX == 2844 && p.absY == 2955) {
		p.setCoords(2844, 2955, 1);
		}
		if (p.absX == 2859 && p.absY == 2954 || p.absX == 2860 && p.absY == 2953 || p.absX == 2860 && p.absY == 2955) {
		p.setCoords(2859, 2954, 1);
	    }
	}
		break;
	    case 2268: //first floor to second floor
	    {
	      if (p.rights >= 1) {
                //if (p.absX == 2861 && p.absY == 2995) {
                if (p.absX == 2861 && p.absY == 2995 || p.absX == 2862 && p.absY == 2996 || p.absX == 2860 && p.absY == 2996) {
		p.setCoords(2861, 2995, 2);
		p.message("welcome to the staff zone.");
	    }
		else {
		  p.message("this place is under construction, and is Staff Only.");
		}
	}
    }
		break;
	    case 2269: //second floor to first floor
	    {
	      if (p.rights >= 1) {
                //if (p.absX == 2861 && p.absY == 2995) {
                if (p.absX == 2861 && p.absY == 2995 || p.absX == 2862 && p.absY == 2996 || p.absX == 2860 && p.absY == 2996) {
		p.setCoords(2861, 2995, 1);
		p.message("you leave the Staff Zone.");
	    }
	}
    }
		break;
	    case 1746: //first floor to ground
	    {
                //if (p.absX == 2861 && p.absY == 2998) {
                if (p.absX == 2861 && p.absY == 2998 || p.absX == 2860 && p.absY == 2997 || p.absX == 2862 && p.absY == 2997) {
		p.setCoords(2861, 2998, 0);
		}
		if (p.absX == 2844 && p.absY == 2955 || p.absX == 2845 && p.absY == 2954 || p.absX == 2844 && p.absY == 2953) {
		p.setCoords(2844, 2955, 0);
		}
		if (p.absX == 2859 && p.absY == 2954 || p.absX == 2860 && p.absY == 2953 || p.absX == 2860 && p.absY == 2955) {
		p.setCoords(2860, 2953, 0);
	    }
	}
		break;
	    case 1750: //ground level to first floor
	    {
                //if (p.absX == 2861 && p.absY == 2998) {
                if (p.absX == 2861 && p.absY == 2998 || p.absX == 2860 && p.absY == 2997 || p.absX == 2862 && p.absY == 2997) {
		p.setCoords(2861, 2998, 1);
	    }
	}
		break;
	     case 39515:
	    {
                if (p.wildernessZone(p.absX, p.absY)) {
                    p.message("You cannot teleport whilst in the wilderness.");
                    return;
                }
		    p.message("You Teleport Home.");
		    p.teleportTo(2440, 3090, 0);
	    }
		break;
             case 2479://mind altar
            {
	        p.runecrafting.runecrafting(p, 1, 360, 558, 14, 28, 42, 56, 70, 84, 98, 150, 150);
            }
                break;
             case 2480:
             {
            p.runecrafting.runecrafting(p, 5, 400, 555, 19, 38, 57, 76, 95, 150, 150, 150, 150);
             }
                break;
            case 2481:
            {
            p.runecrafting.runecrafting(p, 9, 440, 557, 26, 52, 78, 150, 150, 150, 150, 150, 150);
            }
                break;
            case 2482:
            {
            p.runecrafting.runecrafting(p, 14, 500, 554, 35, 70, 150, 150, 150, 150, 150, 150, 150);
            }
                break;
            case 2483:
            {
            p.runecrafting.runecrafting(p, 20, 550, 559, 46, 92, 150, 150, 150, 150, 150, 150, 150);
            }
                break;
            case 2484:
            {
            p.runecrafting.runecrafting(p, 27, 640, 564, 59, 150, 150, 150, 150, 150, 150, 150, 150);
            }
                break;
            case 2485:
            {
            p.runecrafting.runecrafting(p, 54, 1400, 563, 150, 150, 150, 150, 150, 150, 150, 150, 150);
            }
                break;
            case 2486:
            {
            p.runecrafting.runecrafting(p, 44, 1200, 561, 91, 150, 150, 150, 150, 150, 150, 150, 150);
            }
                break;
            case 2487:
            {
            p.runecrafting.runecrafting(p, 35, 780, 562, 74, 150, 150, 150, 150, 150, 150, 150, 150);
            }
                break;
            case 2488:
            {
            p.runecrafting.runecrafting(p, 65, 2000, 560, 150, 150, 150, 150, 150, 150, 150, 150, 150);
            }
                break;
           case 7134: //Chaos
                p.teleportTo(2281, 4837, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7135: //Law
                p.teleportTo(2464, 4818, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7136: //Death
                p.teleportTo(2208, 4830, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7137: //Water
                p.teleportTo(3494, 4831, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7138: //Astral
                p.teleportTo(2154, 3866, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7139: //Air
                p.teleportTo(2793, 4828, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7140: //Mind
                p.teleportTo(2793, 4828, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7131: //Body
                p.teleportTo(2521, 4834, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7130: //Earth
                p.teleportTo(2655, 4830, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7129: //Fire
                p.teleportTo(2577, 4845, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7132: //Cosmic
                p.teleportTo(2162, 4833, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
            case 7133: //Nature
                p.teleportTo(2400, 4835, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
                break;
case 2094:
        case 2095:
        case 31077:
        case 31078:
        case 31079:
        Engine.playerItems.hasPlayerItemAmount(p, 1265, 1);
        p.appendExperience(100, 14);
        p.clickDelay = 4;
        if (p.skillLvl[14] <= 1);
        p.requestAnim(6752, 0);
              Engine.playerItems.addItem(p, 438, 1);
        p.getActionSender().sendMessage(p, "You mine some tin ore.");
        break;

        case 2091:
        case 31080:
        case 31081:
        case 31082:
        Engine.playerItems.hasPlayerItemAmount(p, 1265, 1);
        p.appendExperience(100, 14);
        p.clickDelay = 4;
        if (p.skillLvl[14] <= 1);
        p.requestAnim(6752, 0);
              Engine.playerItems.addItem(p, 436, 1);
        p.getActionSender().sendMessage(p, "You mine some copper ore.");
        break;

        case 2092:
        case 2093:
        case 31071:
        case 31072:
        case 31073:
        Engine.playerItems.hasPlayerItemAmount(p, 1265, 1);
        p.appendExperience(100, 14);
        p.clickDelay = 11;
        if (p.skillLvl[14] <= 20);
        p.requestAnim(6752, 0);
              Engine.playerItems.addItem(p, 500, 1);
        p.getActionSender().sendMessage(p, "You mine some iron ore.");
        break;

        case 2096:
        case 31068:
        case 31069:
        case 31070:
        Engine.playerItems.hasPlayerItemAmount(p, 1265, 1);
        p.appendExperience(225, 14);
        p.clickDelay = 10;
        if (p.skillLvl[14] <= 30);
        p.requestAnim(6752, 0);
              Engine.playerItems.addItem(p, 453, 1);
        p.getActionSender().sendMessage(p, "You mine some coal.");
        break;

        case 2103:
        case 31086:
        case 31087:
        case 31088:
        Engine.playerItems.hasPlayerItemAmount(p, 1265, 1);
        p.appendExperience(300, 14);
        p.clickDelay = 14;
        if (p.skillLvl[14] <= 55);
        p.requestAnim(6752, 0);
              Engine.playerItems.addItem(p, 447, 1);
        p.getActionSender().sendMessage(p, "You mine some mithril ore.");
        break;

        case 31083:
        case 31085:
        Engine.playerItems.hasPlayerItemAmount(p, 1265, 1);
        p.appendExperience(590, 14);
        p.clickDelay = 20;
        if (p.skillLvl[14] <= 70);
        p.requestAnim(6752, 0);
              Engine.playerItems.addItem(p, 449, 1);
        p.getActionSender().sendMessage(p, "You mine some adamant ore.");
        break;

        case 2106:
        case 2107:
        Engine.playerItems.hasPlayerItemAmount(p, 1265, 1);
        p.appendExperience(1200, 14);
        p.clickDelay = 25;
        if (p.skillLvl[14] <= 85);
        p.requestAnim(6752, 0);
              Engine.playerItems.addItem(p, 451, 1);
        p.getActionSender().sendMessage(p, "You mine some runite ore.");
        break;

        //start fishing
// made by kingdhum of run3-s3rv3r and runelocus!
//start shrimps
case 2031:
p.appendExperience(100, 10);
p.clickDelay = 6;
p.requestAnim(10009, 0);
Engine.playerItems.addItem(p, 317, 1);
p.getActionSender().sendMessage(p, "You caught a shrimp!");
break;
//end shrimps
//start sardine
case 8986:
if (p.skillLvl[10] <= 10);
p.appendExperience(150, 10);
p.clickDelay = 6;
p.requestAnim(10009, 0);
Engine.playerItems.addItem(p, 327, 1);
p.getActionSender().sendMessage(p, "You caught a sardine!");
break;
//end sardine
//start herring
case 3032:
if (p.skillLvl[10] <= 30);
p.appendExperience(250, 10);
p.clickDelay = 6;
p.requestAnim(10009, 0);
Engine.playerItems.addItem(p, 345, 1);
p.getActionSender().sendMessage(p, "You caught a herring!");
break;
//end herring
//start salmon
case 2028:
if (p.skillLvl[10] <= 55);
p.appendExperience(600, 10);
p.clickDelay = 6;
p.requestAnim(10009, 0);
Engine.playerItems.addItem(p, 331, 1);
p.getActionSender().sendMessage(p, "You caught a salmon!");
break;
//end salmon
//start lobster
case 2029:
if (p.skillLvl[10] <= 65);
p.appendExperience(1000, 10);
p.clickDelay = 6;
p.requestAnim(10009, 0);
Engine.playerItems.addItem(p, 377, 1);
p.getActionSender().sendMessage(p, "You caught a lobster!");
break;
//end lobster
//start shark
case 2030:
if (p.skillLvl[10] <= 80);
p.appendExperience(1750, 10);
p.clickDelay = 6;
p.requestAnim(10009, 0);
Engine.playerItems.addItem(p, 383, 1);
p.getActionSender().sendMessage(p, "You caught a shark!");
break;
//end shark
//end fishing
     
      case 2285:
        /**
          * Climbing things.
          */
        if (p.agilityDelay == 0) {
            for (int i = 0; i < p.agilityX.length; i++) {
              for (int j = 0; j < p.agilityY.length; j++) {
                  if (p.absX == p.agilityX[i] && p.absY == p.agilityY[j]) {
                    p.requestAnim(828, 0);
                    pm.setAgilityType(2);
                    pm.setAgilityPerforming(true);
                    pm.setAgilityDelay(3);
                    p.appendExperience(3000, 16);
                  }
              }
            }
        }
      break;

      case 2295:
        /**
          * Log obstacle thing.
          */
        if (p.agilityDelay == 0) {
            if (p.absX == 2474 && p.absY == 3436) {
              p.playerWalk(2474, 3429, p.playerWeapon.getWalkEmote(p.equipment[3]), 0);
              pm.setAgilityType(1);
              pm.setAgilityPerforming(true);
              pm.setAgilityDelay(8);
                    p.appendExperience(3000, 16);
            }
        }
      break;

      case 2312:
        /**
          * Walking rope
          */
        if (p.agilityDelay == 0) {
            if (p.absX == 2477 && p.absY == 3420 && p.heightLevel == 2) {
              p.playerWalk(2483, 3420, p.playerWeapon.getWalkEmote(p.equipment[3]), 0);
              pm.setAgilityType(3);
              pm.setAgilityPerforming(true);
              pm.setAgilityDelay(8);
                    p.appendExperience(3000, 16);
            }
        }
      break;

      case 2314:
        /**
          * Tree branch
          */
        if (p.agilityDelay == 0) {
            if (p.absX == 2486 && p.absY == 3420 ||
                p.absX == 2485 && p.absY == 3419) {
              p.requestAnim(828, 0);
              pm.setAgilityType(4);
              pm.setAgilityPerforming(true);
              pm.setAgilityDelay(3);
                    p.appendExperience(3000, 16);
            }
        }
      break;

      case 2286:
        /**
          * Another things of climbing ****.
          */
        if (p.agilityDelay == 0) {
            if (Misc.getDistance(p.absX, p.absY, p.clickX, p.clickY) <= 2) {
              p.requestAnim(828, 0);
              pm.setAgilityType(5);
              pm.setAgilityPerforming(true);
              pm.setAgilityDelay(3);
                    p.appendExperience(3000, 16);
            }
        }
      break;

      case 154:
      case 4058:
        /**
          * Obstacle pipe
          */
        if (p.agilityDelay == 0) {
            if (p.absX == 2487 && p.absY == 3430) {
              p.requestAnim(746, 0);
              p.playerWalk(2487, 3437, 749, 0);
              pm.setAgilityType(6);
              pm.setAgilityPerforming(true);
              pm.setAgilityDelay(8);
                    p.appendExperience(3000, 16);
            } else if (p.absX == 2484 && p.absY == 3430) {
              p.requestAnim(746, 0);
              p.playerWalk(2484, 3437, 749, 0);
              pm.setAgilityType(6);
              pm.setAgilityPerforming(true);
              pm.setAgilityDelay(8);
                    p.appendExperience(3000, 16);
            }
        }
      break;

      case 28119:
      if(p.combatLevel > 67) {
          p.getActionSender().sendMessage(p, "Your combat level is too high for this crator.");
          return;
      }
      Engine.BountyHunter.enter(p, 1);
      break;
      case 28120:
      if(p.combatLevel < 55) {
          p.getActionSender().sendMessage(p, "Your combat level is too low for this crator.");
          return;
      }
      if(p.combatLevel > 113) {
          p.getActionSender().sendMessage(p, "Your combat level is too high for this crator.");
          return;
      }
      Engine.BountyHunter.enter(p, 2);
      break;
      case 28121:
      if(p.combatLevel < 100) {
          p.getActionSender().sendMessage(p, "Your combat level is too low for this crator.");
          return;
      }
      Engine.BountyHunter.enter(p, 0);
      break;
      case 28122:
      int ii = p.heightLevel;
      if(ii == 0) {
          Engine.BountyHunter.exit(p, 1);
      } else if(ii == 4) {
          Engine.BountyHunter.exit(p, 2);
      } else if(ii == 8) {
          Engine.BountyHunter.exit(p, 3);
      }
      break;
case 2561: //bake stall
if (p.skillLvl[17] < 1){
p.Thieving(p, 995, 1, 200, 1000);
        } else {
            p.getActionSender().sendMessage(p, "You need 1 thieving to thiev from here.");
}
break;


case 2560: //silk stall
if (p.skillLvl[17] < 50){
p.Thieving(p, 995, 20, 400, 3000);
        } else {
            p.getActionSender().sendMessage(p, "You need 50 thieving to thiev from here.");
}
break;



case 2562: //Gem stall
if (p.skillLvl[17] < 70){
p.Thieving(p, 995, 75, 1000, 6000);
        } else {
            p.getActionSender().sendMessage(p, "You need 70 thieving to thiev from here.");
}

break;



      case 26289:
      case 26288:
      case 24343:
      case 27661:
      case 409:
      case 37985:
      case 19145:
        if (p.skillLvl[5] != p.getLevelForXP(5)) {
            p.requestAnim(645, 0);
            p.skillLvl[5] = p.getLevelForXP(5);
            p.getActionSender().sendMessage(p, "You restore your prayer points.");
        } else {
            p.getActionSender().sendMessage(p, "Your prayer points are still full.");
        }
        p.getActionSender().setSkillLvl(p, 5);
        p.appearanceUpdateReq = true;
        p.updateReq = true;
      break;

            case 1278:
                p.getActionSender().removeShownInterface(p);
                break;

            case 26426: // Armadyl door
                if (p.clickX == 2839 && p.clickY == 5295) {
                    if (p.armadylKills >= 10) {
                        if (p.teleportTo(2839, 5296, 2)) {
                            p.armadylKills = 0;
                            p.message("You enter Armadyl's lair and your armadyl kills are reset.");
                            p.sendGodwarsInterface();
                        }
                    } else {
                        p.message("You need 10 or more Armadyl kills to enter here.");
                    }
                }
                break;
            case 26425: // Bandos door
                if (p.clickX == 2863 && p.clickY == 5354) {
                    if (p.bandosKills >= 10) {
                        if (p.teleportTo(2864, 5354, 2)) {
                            p.bandosKills = 0;
                            p.message("You enter Bando's lair and your bandos kills are reset.");
                            p.sendGodwarsInterface();
                        }
                    } else {
                        p.message("You need 10 or more Bandos kills to get in here!");
                    }
                }
                break;
            case 26427: // Saradomin door
                if (p.clickX == 2908 && p.clickY == 5265) {
                    if (p.saradominKills >= 10) {
                        if (p.teleportTo(2907, 5265, 0)) {
                            p.saradominKills = 0;
                            p.message("You enter Saradomin's lair and your saradomin kills are reset.");
                            p.sendGodwarsInterface();
                        }
                    } else {
                        p.message("You need 10 or more Saradomin kills to get in here!");
                    }
                }
                break;
            case 26428: // Zamorak door
                if (p.clickX == 2925 && p.clickY == 5332) {
                    if (p.zamorakKills >= 10) {
                        if (p.teleportTo(2925, 5331, 2)) {
                            p.zamorakKills = 0;
                            p.message("You enter Zamorak's lair and your zamorak kills are reset.");
                            p.sendGodwarsInterface();
                        }
                    } else {
                        p.message("You need 10 or more Zamorak kills to get in here!");
                    }
                }
                break;

            case 10284: // Barrows chest
                if (p.clickX == 3551 && p.clickY == 9695) {
                    if (p.barrowsStage == 7) {
                        if (Engine.playerItems.freeSlotCount(p) > 0) {
                            if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 3) {
                                p.message("You open the chest...");
                                p.requestAnim(2246, 0);
                                int reward = p.getBarrowsReward();
                                Engine.playerItems.addItem(p, reward, 1);
                                p.barrowsStage = 0;
                                p.actionSender.removeOverlay(p);
                                // Now lets update wilderness overlay again
                                p.removedWildy = false;
                                p.wildernessZone(p.absX, p.absY);
                                // Tell them what they got
                                p.message("...and find a " + Engine.items.getItemName(reward) + "!");
                                // Now get the player out of here
                                p.teleportTo(3124, 9882, 0, true);
                            }
                        } else {
                            p.message("You cannot open the chest with no free space!");
                        }
                    } else {
                        p.message("You shouldn't be here. Go away.");
                        p.teleportTo(3124, 9882, 0, true);
                    }
                }
                break;

            case 26933:
                if (p.clickX == 3097 && p.clickY == 3468) {
                    // Trapdoor to Edge dung
                    if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
                        p.heightLevel = 0;
                        p.setCoords(3096, 9867);
                        p.message("You enter the trapdoor!");
                    }
                }
                break;
            case 29355:
                if (p.clickX == 3097 && p.clickY == 9867) {
                    // Ladders to Edge from edge dung
                    if (Misc.getDistance(p.clickX, p.clickY, p.absX, p.absY) <= 2) {
                        p.heightLevel = 0;
                        p.setCoords(3096, 3468);
                        p.message("You climb the ladders.");
                    }
                }
                break;

            case 23271:
                p.jumpDelay = 5;
                if (p.absY > p.clickY) {
                    p.jumpUpdateReq = true;
                    p.reqWalkQueueBack(p.absX, p.clickY - 1);
                }
                if (p.absY < p.clickY) {
                    p.jumpUpdateReq = false;
                    p.reqWalkQueue(p.absX, p.clickY + 2);
                }
                break;

                //case 9312: //Ge Thing
                //  teleportTo(3138, 3516, 4, 3, 0, 0, 0, 0, 0, 0, 0);
                //  break;
                //  case 9311: //Ge Thing
                //      teleportTo(3143, 3514, 4, 3, 0, 0, 0, 0, 0, 0, 0);
                //  break;
            case 1814: //Ardougne Lever
                p.leverTeleport("Deep Wilderness");
                break;
            case 1815: //Deep Wilderness
                p.leverTeleport("Ardougne Lever");
                break;
            case 5959: //Mage Bank (Outside)
                p.leverTeleport("Mage Bank (Inside)");
                break;
            case 5960: //Mage Bank (Inside)
                p.leverTeleport("Mage Bank (Outside)");
                break;
        case 4483: //Bank Chest
            p.openBank();
            break;
        case 7289: //funpk portal
                p.teleportTo(2440, 3090, 0);
            break;
               
                //case 1816: //
                //break;
                //case 1817: //
                //break;
            case 35543:
                if (p.absX == 3304 && p.absY == 3117 && p.heightLevel == 0) {
                    p.setCoords(3304, 3115, 0);
                } else if (p.absX == 3304 && p.absY == 3115 && p.heightLevel == 0) {
                    p.setCoords(3304, 3117, 0);
                }
                break;

            // Woodcutting
            case 1276: // Tree
            case 1307: // Maple
            case 1309: // Yew
            case 1306: // Magic
                p.woodcutting.startWoodcutting(p.clickId);
                break;
/*******************************jail quarters**********************/
/**********jail cells************/
        	case 79: //jail doors
        	case 80: //jail doors
        	case 81: //jail doors
        		if (p.absX >= 2614 && p.absY >= 3158 && p.absX <= 2616 && p.absY <= 3170) {
        			int pickLock = Misc.random(200);
        			if (pickLock >= 0 && pickLock <= 199) {
        				p.getActionSender().sendMessage(p, "You fail to Pick the door lock!");
        			} else if (pickLock == 200) {
        				p.setCoords(2618, 3162, 0);
        				p.getActionSender().sendMessage(p, "You successfully pick the lock and escape!");
        			}
        		} else {
        			p.message("Why would you want to go in that stinky old cell anyways?");
        		}
        		break;
            
            
    case 41125: //exit door
	case 41522: //door to outside(second floor)
		p.message("This door is locked!");
		break;
	case 41501:
		p.message("I don't think he wants to talk....");
		break;
	case 41129: //door to office and JAIL cell room
		if (p.absX >= 2615 && p.absX <= 2617 && p.absY == 3147) { //door to office?
		p.setCoords(2616, 3146, 0);
		} else if (p.absX >= 2615 && p.absX <= 2617 && p.absY == 3146) { //door to actual jail??
		p.setCoords(2616, 3147, 0);
		}
		break;
	case 41121: // stairs to second floor
		if (p.absX == 2615 && p.absY >= 3139 && p.absY <= 3140) {
		p.setCoords(2612, 3140, 1);
		}
		break;
	case 41122: // stairs to first floor
		if (p.absX == 2612 && p.absY >= 3139 && p.absY <= 3140) {
		p.setCoords(2615, 3140, 0);
		}
		break;
	case 41078: //ladder to staff zone
		if ((p.absX == 2619 && p.absY == 3139) && p.rights >= 1) {
		p.setCoords(2619, 3141, 2);
		} else if (p.rights == 0) {
		p.message("STAFF ONLY");
		}
		break;
	case 41079: //ladder to high pen jail room
		if (p.absX == 2619 && p.absY == 3141) {
		p.setCoords(2619, 3139, 1);
		}
		break;
            default:
                    Misc.println("[" + p.username + "] Unhandled object 1: " + p.clickId);
                break;
        }

        // FACE: 0= WEST | -1 = NORTH | -2 = EAST | -3 = SOUTH
        // ObjectType: 0-3 wall objects, 4-8 wall decoration, 9: diag.
        // walls, 10-11 world objects, 12-21: roofs, 22: floor decoration
        for (int d = 0; d < Engine.doorHandler.doorX.length; d++) {
            if ((p.clickId == Engine.doorHandler.doorId[d]) && (p.clickX == Engine.doorHandler.doorX[d])
                    && (p.clickY == Engine.doorHandler.doorY[d])) {
                int newFace = Engine.doorHandler.doorFaceOpen[d];
                for (int j = 0; j < Engine.players.length; j++) {
                    Player player = Engine.players[j];
                    if (player == null)
                        continue;
                    if ((player.username != null)
                            && (player.heightLevel == p.heightLevel)
                            && !player.disconnected[0] && (player.absY > 0)
                            && (player.absX > 0)) {
                        if (Misc.getDistance(player.absX, player.absY, Engine.doorHandler.doorX[d],
                                Engine.doorHandler.doorY[d]) <= 17) {
                            Engine.actionSender.addObject(player, Engine.doorHandler.doorId[d],
                                    Engine.doorHandler.doorHeight[d], Engine.doorHandler.doorX[d],
                                    Engine.doorHandler.doorY[d], newFace, 0);
                        }
                    }
                }
            }
        }

    }

    private int objectSize(int id) {
        switch (id) {
            default:
                return 1;
        }
    }
} 